import http from '../utils/axios';
const h = 'http://dsq.ljc.icu:8080'
// const h = 'http://43.136.173.124:8080'
interface dataType{
    num:number,
    size:number
}
interface searchData{
    date: string,
    num: number,
    size: number,
    state: number,
    title: string
}
//添加抵扣时的参数类型 
interface AddDeduction{
    standard: number,
    title: string,
    type: number
}
//抵扣页面编辑泛型
interface eductionCompileProps{
    id?:number,
    standard?:number,
    title?:string,
    type?:number
}
//抢购模糊查询
interface purchaseSearchProps{
    num ?: number,//页码
    size ?: number,//页码条数
    sort ?: number,//sort 1：创建时间从小到大（升序） 2：从小到大（降序）
    state ?: number,//上下架状态
    time ?: string,//时间
    title ?: string//标题
}
//添加抢购
interface props{
    trTitle?:string,
    trMileage?:number,
    trType?:number,
    trStart?:string,
    trEnd?:string,
    trGoods?:string,
    trCreate?:string,
    trAdvance?:string,
    trState?:number
}
//查询所有促销或模糊查询
// interface PromotionGetProps {
//     date?: string,
//     num:number,
//     size:number,
//     sort?: number,
//     state?: number,
//     title?: string
// }
interface SearchType{ 
    title: string , 
    state?: {}, 
    creat: string  ,
    num:number,
    size:number
}

interface addPromotionData{
    advance: string,
    create?:string,
    deleted?: number,
    end: string,
    id?: number,
    price: number,
    sport: number,
    start: string,
    state: number,
    title: string
}
//1、促销管理======================================================================================
//获取促销界面但前页数据
export const getAllPromotion = (data:SearchType)=>{
    return http.post(h+"/shopping-mall/promotion/findAll",data)
}
//根据ID删除促销
export const delData = (data:{id:number})=>{
    return http.get(h+'/shopping-mall/promotion/del',data)
}
//添加促销
export const addData = (data:addPromotionData)=>{
    return http.post(h+'/shopping-mall/promotion/add',data)
}
//查询参加这个促销的商品
export const goodsValue = (data:{id:number,sort?:number,num:number,size:number})=>{
    return http.post(h+'/shopping-mall/promotion/findGoods',data)
}
//根据id修改上下架状态
export const changePromotionState = (data:{id:number})=>{
    return http.get<any>(h+'/shopping-mall/promotion/state',data)
}
//删除商品
export const delGoodsApi = (data:{id:number,pro:number})=>{
    return http.post<any>(h+'/shopping-mall/promotion/delGoods',data)
}
//进入商品添加页面
//进入添加页面我会把所有一级分类和品牌传出，allOne:所有一级分类，allBrand:所有品牌
export const allBrandApi = ()=>{
    return  http.get<any>(h+'/shopping-mall/promotion/initAdd')
}
//查询所有不在这个促销里的商品
export const elaseApi = (data:{id:number})=>{
    return  http.post<any>(h+'/shopping-mall/promotion/findGoodsByIdNotInVo',data)
}
//根据一级分类查二级分类
export const twoApi = (data:{id:number})=>{
    return  http.get<any>(h+'/shopping-mall/promotion/findTwo',data)
}
//2、抢购管理接口======================================================================================
//抢购管理获取单页总数据
export const purchaseApi = (data:{num:number,size:number})=>{
    return http.post<any>(h +'/shopping-mall/rush/findAll',data)
}
//抢购管理模糊查询
export const purchaseSearch = (data:purchaseSearchProps)=>{
    return http.post<any>(h+'/shopping-mall/rush/dim',data)
}
//抢购管理添加
export const AddPurchaseList = (data:props)=>{
    return http.post<any>(h+'/shopping-mall/rush/add',data)
}
//改变抵扣上下架状态
export const changePurchaseState = (data:{id:number})=>{
    return http.get<any>(h+'/shopping-mall/rush/updateState',data)
}
//通过id修改抵扣页面的信息
export const editorPurchase = (data:{title:string,goods:string,start:string})=>{
    return http.post<any>(h+'/shopping-mall/rush/updateById',data)
}
//通过id删除单个数据
export const delPurchase = (data:{id:number})=>{
    return http.get<any>(h+"/shopping-mall/rush/deleteOne",data)
}
//编辑时用到的商品表数据
export const getGoods = ()=>{
    return http.get<any>(h+"/shopping-mall/rush/findAllGoods")
}
// 3、抵扣管理接口=====================================================================================
//抵扣管理数据获取
export const deductionApi = (data:dataType) =>{
    return http.post<any>(h + '/shopping-mall/deduction/findAll',data)
} 
//抵扣管理的模糊查询
export const deductionSearchApi = (data:searchData) => {
    return http.post<any>(h + '/shopping-mall/deduction/dimFind',data)
}
//抵扣管理添加抵扣
export const addDeductionApi = (data:AddDeduction)=>{
    return http.post<any>(h+'/shopping-mall/deduction/add',data)
}
//所有适用行程数据
export const deTypeApi = ()=>{
    return http.get<any>(h+'/shopping-mall/deduction/addInt')
}
//抵扣管理单项数据删除
export const DelDeductionApi = (data:{id:number})=>{
    return http.get<any>(h+'/shopping-mall/deduction/deleteDeduction',data)
}
//修改抵扣管理界面相应的上架和未上架状态
export const changeDeductionStateApi = (data:{id:number})=>{
    return http.get<any>(h+'/shopping-mall/deduction/updateState',data)
}
//抵扣管理的编辑请求
export const deductionCompile = (data:eductionCompileProps) => {
    return http.post<any>(h+'/shopping-mall/deduction/updateDeStandardById',data )
}



